package znbkCNtxl;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v4.view.ViewPager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.text.SpannableString;
import android.text.method.LinkMovementMethod;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.example.znbk.znbklibrary.base.BaseLongActivity;
import com.example.znbk.znbklibrary.dialog.LoadingDialog;
import com.example.znbk.znbklibrary.util.LancooUtils;
import com.example.znbk.znbklibrary.widget.ControlScrollViewPager;
import com.lancoo.znbkxx.R;
import com.lancoo.znbkxx.beans.UserInfoBean;
import com.lancoo.znbkxx.fragments.ProblemTrainingFragment;
import com.lancoo.znbkxx.fragments.WrongQuestionFragment;
import com.lancoo.znbkxx.net.URLConstant;
import com.lancoo.znbkxx.uis.PhoneMainActivity;
import com.example.znbk.znbklibrary.base.AnswerViewPagerAdapter;
import com.example.znbk.znbklibrary.base.BaseFragment;
import com.example.znbk.znbklibrary.base.BaseFragmentPagerAdapter;
import com.example.znbk.znbklibrary.dialog.ExitDialog;
import com.example.znbk.znbklibrary.widget.ScaleButton;
import com.google.gson.Gson;
import com.tt.SkEgnManager;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import znbkBkfx.AboutCountDowm.CountDownView;
import znbkBkfx.AboutKnowledgePoint.HighLightKeyWordUtil;
import znbkBkfx.PostCollectionJson.PostCollectionJson;
import znbkBkfx.PostCollectionJson.PostCollection_interface;
import znbkCNtxl.CNTXL_GCT.CNtxlGctFragment;
import znbkCNtxl.CNTXL_PPT.CNtxlPptAnswerAdapter;
import znbkCNtxl.CNTXL_TKT.CNtxlTktAnswerAdapter;
import znbkCNtxl.CNTXL_TKT.CNtxlTktFragment;
import znbkCNtxl.CNTXL_DXT.CNtxlDxtAnswerAdapter;
import znbkCNtxl.CNTXL_DXT.CNtxlDxtFragment;
import znbkCNtxl.CNTXL_PPT.CNtxlPptFragment;
import znbkCNtxl.CNTXL_TLTK.CNtxlTltkFragment;
import znbkCNtxl.CNTXL_TLXZ.CNtxlTlxzAnswerAdapter;
import znbkCNtxl.CNTXL_TLXZ.CNtxlTlxzFragment;
import znbkCNtxl.CNTXL_WXXZ.CNtxlWxxzAnswerAdapter;
import znbkCNtxl.CNTXL_WXXZ.CNtxlWxxzFragment;
import znbkCNtxl.CNTXL_YDJD.CNtxlYdjdAnswerAdapter;
import znbkCNtxl.CNTXL_YDJD.CNtxlYdjdFragment;
import znbkCNtxl.CNTXL_YDXZ.CNtxlYdxzAnswerAdapter;
import znbkCNtxl.CNTXL_YDXZ.CNtxlYdxzFragment;
import znbkCNtxl.CNTXL_YDZH.CNtxlYdzhAnswerAdapter_jd;
import znbkCNtxl.CNTXL_YDZH.CNtxlYdzhAnswerAdapter_tk;
import znbkCNtxl.CNTXL_YDZH.CNtxlYdzhFragment;
import znbkCNtxl.GetNtxlJson.CNtxlPaperEntity;
import znbkCNtxl.GetNtxlJson.PostCNtxlJsonBody;
import znbkCNtxl.GetNtxlJson.PostRequest_CNtxlInterface;
import okhttp3.RequestBody;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import znbkCNtxl.PostSaveCNtxlAnswer.PostSubmitKgtQuesAnswer_Interface;
import znbkCNtxl.PostSaveCNtxlAnswer.PostSubmitZgtQuesAnswer_Interface;
import znbkCNtxl.PostSaveCNtxlAnswer.ResultZgtJson;
import znbkCNtxl.PostSaveCNtxlAnswer.SubmitQuesAnswerModel;
import znbkSameQuesTranslate.GetSameQuesJson.SameQuesInitParam;
import znbkSameQuesTranslate.SameQuesActivity;

public class CNtxlActivity extends BaseLongActivity {

    /*
     * 单选题     A---------------@
     * 听力填空   S-----------------@--------------7
     * 词汇填空   N-----------------@---------6
     * 阅读填空   Q-----------------@---------6
     * 听力选择   E-----------------@----3
     * 阅读选择   D-----------------@-----4
     * 完形选择   C-----------------@-------5
     * 改错题     U
     * 词汇匹配   m-----------------@---2
     * 补全对话   b-----------------@--1
     * 看图写句子 d-----------------@--1
     * 阅读简答   X-----------------@--1
     * 翻译题     g-----------------@--1
     * 连词成句   V-----------------@--1
     * 阅读综合   k-----------------@--------------------8
     * 作文       f
     * */
    private List<CNtxlPaperEntity> CNtxlPaperEntity;
    int ItemType = -1;
    private void getPaperInfor() {

        boolean ReplaceBlank = true;
        int StartIndex = 1;
        int IsItemReviewed  = 0;
        if(PhoneMainActivity.getCNtxlModel()==2){
            ItemType = 3;
        }else if(PhoneMainActivity.getCNtxlModel()==1){
            ItemType = 1;
        }
        boolean ReplaceUrl = true;

        PostCNtxlJsonBody postCNtxlJsonBody =new PostCNtxlJsonBody();
        postCNtxlJsonBody.setIsItemReviewed(IsItemReviewed);
        if(PhoneMainActivity.getCNtxlModel()==1){
            postCNtxlJsonBody.setQuesID(WrongQuestionFragment.getQuesID());
        }else if(PhoneMainActivity.getCNtxlModel()==2){
            postCNtxlJsonBody.setQuesID(ProblemTrainingFragment.getQuesID());
        }
        postCNtxlJsonBody.setKey(UserInfoBean.Key);
        postCNtxlJsonBody.setCourseClassID(UserInfoBean.CourseClassID);
        postCNtxlJsonBody.setReplaceBlank(ReplaceBlank);
        postCNtxlJsonBody.setReplaceUrl(ReplaceUrl);
        postCNtxlJsonBody.setItemType(ItemType);
        postCNtxlJsonBody.setSchoolID(UserInfoBean.SchoolID);
        postCNtxlJsonBody.setGlobalGrade(UserInfoBean.GlobalGrade);
        postCNtxlJsonBody.setStartIndex(StartIndex);
        postCNtxlJsonBody.setStuID(UserInfoBean.StuId);
        postCNtxlJsonBody.setSubjectID(UserInfoBean.CNTSubjectID);
        Gson gson=new Gson();
        String BODY= gson.toJson(postCNtxlJsonBody);
        Log.e("==BODY_CNTXL=","========BODY====请求参数(错难题)============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory( GsonConverterFactory.create())
        .build();
        PostRequest_CNtxlInterface postRequest = retrofit.create(PostRequest_CNtxlInterface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<List<CNtxlPaperEntity>> call = postRequest.getNtxlPaperInfor(body);
        call.enqueue(new Callback<List<CNtxlPaperEntity>>() {
            @Override
            public void onResponse(Call<List<CNtxlPaperEntity>> call, Response<List<CNtxlPaperEntity>> response) {
                Log.e("onResponse==wwwwww=","===cntxlPaper=====http============="+response);
                CNtxlPaperEntity = response.body();
                Log.e("onResponse===AAAWAA=","======cntxlPaper=========json============="+CNtxlPaperEntity);
                if(CNtxlPaperEntity.size()==0){
                    LancooUtils.showShort(CNtxlActivity.this,"数据有误");
                    mIvNoPaper.setVisibility(View.VISIBLE);
                }else {
                    doBusiness();
                }

                mLoadingDialog.dismiss();
            }

            @Override
            public void onFailure(Call<List<CNtxlPaperEntity>> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
                mLoadingDialog.dismiss();
            }
        });

    }


    @Override
    protected int setLayout() {
        return R.layout.activity_ntxlpaper;
    }

    private int currentPageIndex = 0;//记录当前试题页的地址页码
    private ScaleButton mSBtnBack;//返回按钮
    private TextView mTvPracticeName;//练习名称
    private ScaleButton mSBtnAnswerNote;//笔记按钮
    private ScaleButton mSBtnAnswerCollection;//收藏按钮
    private TextView mTvQuesInfor;//试题信息
    public static ControlScrollViewPager mVpCNtxl;
    private ImageView mIvNoPaper;
    private List<BaseFragment> mFragmentList;
    private BaseFragmentPagerAdapter mNtxlFragmentAdapter;
    private LoadingDialog mLoadingDialog;
    private RelativeLayout mRlControlView;
    private ScaleButton mSBtnSameQuesTranslate;
    @Override
    protected void initView() {

        currentPageIndex = 0;
        mLoadingDialog = new LoadingDialog(this,false,false,"难题加载中");
        mLoadingDialog.show();

        mSBtnBack = findViewById(R.id.sbtn_back);
        mSBtnBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Log.e("back","=====================返回back=====");
                showExitDialog();
            }
        });
        mTvPracticeName = findViewById(R.id.tv_practiceName);
        mSBtnAnswerNote = findViewById(R.id.sbtn_answerNote);
        mSBtnAnswerCollection = findViewById(R.id.sbtn_answerCollection);

        mTvQuesInfor = findViewById(R.id.tv_quesInfor);
        mVpCNtxl =  findViewById(R.id.vp_cntxl);
        mIvNoPaper = findViewById(R.id.iv_noPaper);
        mIvNoPaper.setVisibility(View.GONE);
        getPaperInfor();


    }

    public void doBusiness() {
        /*处理业务操作*/
        showPracticeName();//显示训练的名称
        loadQuesFragment();//加载作答Fragment页面
    }

    private void showPracticeName(){
        Log.e("CNtxlModel()","========================================"+PhoneMainActivity.getCNtxlModel());
        if(PhoneMainActivity.getCNtxlModel()==1){
            mTvPracticeName.setText("错题辅导");
        }else if(PhoneMainActivity.getCNtxlModel()==2){
            mTvPracticeName.setText("难题训练");
        }
    }

    private void loadQuesFragment(){

        final String TypeNo = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
        final int PaperListSize = CNtxlPaperEntity.size();

        if(PhoneMainActivity.getCNtxlModel()==2) {
            mTvQuesInfor.setText(Html.fromHtml(getResources().getString(R.string.ntxl_paper_infor, "难题", 1, PaperListSize)));
        }else if(PhoneMainActivity.getCNtxlModel()==1){
            mTvQuesInfor.setText(Html.fromHtml(getResources().getString(R.string.ntxl_paper_infor, "错题", 1, PaperListSize)));
        }
        mFragmentList = new ArrayList<>();
        mFragmentList.clear();

        for(int i=0;i<PaperListSize;i++) {
            if(TypeNo.equals("A")) {
                mFragmentList.add(new CNtxlDxtFragment(1, CNtxlPaperEntity, i, new CNtxlDxtFragment.CallBackFragmentDxt() {
                    @Override
                    public void submitKgtQuesAnswer() {
                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                        for(int i=0;i<Size;i++){
                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                            if(!ItemAnswer.equals(StuAnswer)){
                                isCanMovePaper = false;
                                break;
                            }
                        }
                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                final Handler mH = new Handler();
                                mH.postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                                        mH.removeCallbacks(this);
                                    }
                                },900);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlDxtFragment fragment = (CNtxlDxtFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入单选题同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);
                    }
                }));
            } if(TypeNo.equals("S")) {
                mFragmentList.add(new CNtxlTltkFragment(1, CNtxlPaperEntity, i, new CNtxlTltkFragment.CallBackFragmentTltk() {
                    @Override
                    public void submitKgtQuesAnswer() {
                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().
                                get(0).getSubChildList().get(0).getSubChildItem().size();
                        for(int i=0;i<Size;i++){
                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                            if(!ItemAnswer.equals(StuAnswer)){
                                isCanMovePaper = false;
                                break;
                            }
                        }
                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlTltkFragment fragment = (CNtxlTltkFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);
                    }
                }));
            }else if(TypeNo.equals("N")||TypeNo.equals("Q")){
                mFragmentList.add(new CNtxlTktFragment(1, CNtxlPaperEntity, i, new CNtxlTktFragment.CallBackFragmentTkt() {
                    @Override
                    public void submitKgtQuesAnswer() {
                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        String GenreName = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getGenreInfo().getGenreName();
                        if(GenreName.equals("选词填空")){
                            int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                            for(int i=0;i<Size;i++){
                                String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                                String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                                if(!ItemAnswer.equals(StuAnswer)){
                                    isCanMovePaper = false;
                                    break;
                                }
                            }
                        }else{
                            int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().size();
                            for(int i=0;i<Size;i++){
                                String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                        get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                                String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                        get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                                if(!ItemAnswer.equals(StuAnswer)){
                                    isCanMovePaper = false;
                                    break;
                                }
                            }
                        }

                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlTktFragment fragment = (CNtxlTktFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入普通填空同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);
                    }

                }));
            }else if(TypeNo.equals("E")){
                mFragmentList.add(new CNtxlTlxzFragment(1, CNtxlPaperEntity,i, new CNtxlTlxzFragment.CallBackFragmentTlxz() {
                    @Override
                    public void submitKgtQuesAnswer() {

                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                        for(int i=0;i<Size;i++){
                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                            if(!ItemAnswer.equals(StuAnswer)){
                                isCanMovePaper = false;
                                break;
                            }
                        }
                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlTlxzFragment fragment = (CNtxlTlxzFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);
                    }

                }));
            }else if(TypeNo.equals("D")){
                mFragmentList.add(new CNtxlYdxzFragment(1, CNtxlPaperEntity,i, new CNtxlYdxzFragment.CallBackFragmentYdxz() {
                    @Override
                    public void submitKgtQuesAnswer() {
                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                        for(int i=0;i<Size;i++){
                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                            if(!ItemAnswer.equals(StuAnswer)){
                                isCanMovePaper = false;
                                break;
                            }
                        }
                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlYdxzFragment fragment = (CNtxlYdxzFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);
                    }

                }));
            }else if(TypeNo.equals("m")){
                mFragmentList.add(new CNtxlPptFragment(1, CNtxlPaperEntity,i, new CNtxlPptFragment.CallBackFragmentPpt() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                        if ((currentPageIndex + 1) < PaperListSize) {
//                            mVpCNtxl.setCurrentItem(currentPageIndex + 1);
//                        } else {
//                            Log.e("==mFragmentList==", "==========E==========没有更多题目了=============");
//                            Toast.makeText(CNtxlActivity.this, "没有更多题目了", Toast.LENGTH_SHORT).show();
//                        }

                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().
                                get(0).getSubChildList().get(0).getSubChildItem().size();
                        for(int i=0;i<Size;i++){
                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                            if(!ItemAnswer.equals(StuAnswer)){
                                isCanMovePaper = false;
                                break;
                            }
                        }
                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlPptFragment fragment = (CNtxlPptFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);

                    }
                }));
            }else if(TypeNo.equals("b")||TypeNo.equals("d")||TypeNo.equals("X")||TypeNo.equals("g")||TypeNo.equals("V")){
                mFragmentList.add(new CNtxlYdjdFragment(1,CNtxlPaperEntity, i, new CNtxlYdjdFragment.CallBackFragmentYdjd() {

                    @Override
                    public void submitZgtQuesAnswer() {
                        SubmitCntxlZgtQuesAnswer(currentPageIndex);
                    }

                }));
            }else if(TypeNo.equals("C")){
                mFragmentList.add(new CNtxlWxxzFragment(1,CNtxlPaperEntity, i, new CNtxlWxxzFragment.CallBackFragmentWxxz() {
                    @Override
                    public void submitKgtQuesAnswer() {
//                        if ((currentPageIndex + 1) < PaperListSize) {
//                            mVpCNtxl.setCurrentItem(currentPageIndex + 1);
//                        } else {
//                            Log.e("==mFragmentList==", "=========A===========没有更多题目了=============");
//                            Toast.makeText(CNtxlActivity.this, "没有更多题目了", Toast.LENGTH_SHORT).show();
//                        }

                        SubmitCntxlKgtQuesAnswer(currentPageIndex);

                        boolean isCanMovePaper = true;
                        int Size = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().
                                get(0).getSubChildList().get(0).getSubChildItem().size();
                        for(int i=0;i<Size;i++){
                            String ItemAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                            String StuAnswer = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                    get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                            if(!ItemAnswer.equals(StuAnswer)){
                                isCanMovePaper = false;
                                break;
                            }
                        }
                        if(isCanMovePaper) {
                            if ((currentPageIndex + 1) < PaperListSize) {
                                mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                            }else {
                                LancooUtils.showShort(CNtxlActivity.this, "没有更多题目了");
                            }
                        }else{
                            LancooUtils.showShort(CNtxlActivity.this, "做得太糟了...");
                            CNtxlWxxzFragment fragment = (CNtxlWxxzFragment) mFragmentList.get(currentPageIndex);
                            mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                            mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                            mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                @Override
                                public void onClick(View v) {
                                    LancooUtils.showShort(CNtxlActivity.this,"进入听力填空同类题训练");
                                    setSameQuesInitParma();
                                }
                            });

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                        mVpCNtxl.setScrollble(true);

                    }

                }));
            }else if(TypeNo.equals("U")){
                mFragmentList.add(new CNtxlGctFragment(1,CNtxlPaperEntity, i, new CNtxlGctFragment.CallBackFragmentGct() {
                    @Override
                    public void pageMoveNext() {
                        if ((currentPageIndex + 1) < PaperListSize) {
                            mVpCNtxl.setCurrentItem(currentPageIndex + 1);
                        } else {
                            Log.e("==mFragmentList==", "=========A===========没有更多题目了=============");
                            Toast.makeText(CNtxlActivity.this, "没有更多题目了", Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void saveItemQuesAnswer() {

                    }

                }));
            }else if(TypeNo.equals("k")){
                mFragmentList.add(new CNtxlYdzhFragment(1,CNtxlPaperEntity, i, new CNtxlYdzhFragment.CallBackFragmentYdzh() {
                    @Override
                    public void submitZgtQuesAnswer() {
                        SubmitCntxlZgtQuesAnswer(currentPageIndex);
                    }
                }));
            }

        }
        mNtxlFragmentAdapter = new BaseFragmentPagerAdapter(getSupportFragmentManager(), mFragmentList);
        mVpCNtxl.setAdapter(mNtxlFragmentAdapter);
        mVpCNtxl.setCurrentItem(0);
        showCollectionInfor(0);
        mVpCNtxl.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }
            @Override
            public void onPageSelected(int position) {

                mVpCNtxl.setScrollble(false);
                final Handler mH = new Handler();
                mH.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        mVpCNtxl.setScrollble(true);
                        mH.removeCallbacks(this);
                    }
                },800);

                showCollectionInfor(position);//刷新收藏情况

                int SubmitState  = CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getSubmitState();
                if(SubmitState!=2) {
                    if (position > currentPageIndex) {
                        CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().setSubmitState(2);
                        doRefreshCurrentPageView(currentPageIndex);
                    }
                }

                currentPageIndex = position;
                if(PhoneMainActivity.getCNtxlModel()==2) {
                    mTvQuesInfor.setText(Html.fromHtml(getResources().getString(R.string.ntxl_paper_infor,"难题",(position+1),PaperListSize)));
                }else if(PhoneMainActivity.getCNtxlModel()==1){
                    mTvQuesInfor.setText(Html.fromHtml(getResources().getString(R.string.ntxl_paper_infor,"错题",(position+1),PaperListSize)));
                }

            }
            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });

    }


    private void showCollectionInfor(final int position){
        boolean IsFavourite = CNtxlPaperEntity.get(position).getFavouriteAndNote().isIsFavourite();
        if(IsFavourite) {
            // 使用代码设置drawableleft
            Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_select);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
            mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
        }else{
            // 使用代码设置drawableleft
            Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_unselect);
            drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
            mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
        }
        mSBtnAnswerCollection.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                boolean IsFavourite = CNtxlPaperEntity.get(position).getFavouriteAndNote().isIsFavourite();
                if(IsFavourite){
                    postCollection(position,0);
                    CNtxlPaperEntity.get(position).getFavouriteAndNote().setIsFavourite(false);
                    Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_unselect);
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
                    mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
                }else{
                    postCollection(position,1);
                    CNtxlPaperEntity.get(position).getFavouriteAndNote().setIsFavourite(true);
                    Drawable drawable = getResources().getDrawable(R.mipmap.topbar_icon_collection_select);
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(),drawable.getMinimumHeight());//这一步必须要做,否则不会显示.
                    mSBtnAnswerCollection.setCompoundDrawables(drawable, null, null, null);
                }
            }
        });
    }

    @Override
    public void onBackPressed() {
        Log.e("back","========BBBBBBBBBBBB=============返回back=====");
        showExitDialog();
    }

    public void showExitDialog(){
        //暂停界面一切动态事务
        String TypeNo = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
        if(TypeNo.equals("E")) {
            Log.e("back","========AAAAAAAAA=============返回back=====");
            CNtxlTlxzFragment fragment = (CNtxlTlxzFragment) mFragmentList.get(currentPageIndex);
            RelativeLayout mRlMyBrowseBg = fragment.getView().findViewById(R.id.rl_myBrowseBg);
            CountDownView mCdvMyBrowse =  fragment.getView().findViewById(R.id.cdv_myBrowse);
            if(mRlMyBrowseBg.getVisibility()==View.VISIBLE) {
                mCdvMyBrowse.pauseCountDown();
                Log.e("back","========mRlMyBrowseBg====00000==============");
            }else{
                if(!fragment.isVoicePlayingEnd){
                    fragment.pause();
                }
            }
        }else if(TypeNo.equals("S")){
            CNtxlTltkFragment fragment = (CNtxlTltkFragment) mFragmentList.get(currentPageIndex);
            RelativeLayout mRlMyBrowseBg = fragment.getView().findViewById(R.id.rl_myBrowseBg);
            CountDownView mCdvMyBrowse =  fragment.getView().findViewById(R.id.cdv_myBrowse);
            if(mRlMyBrowseBg.getVisibility()==View.VISIBLE) {
                mCdvMyBrowse.pauseCountDown();
                Log.e("back","========mRlMyBrowseBg====00000====BBBBB==========");
            }else{
                if(!fragment.isVoicePlayingEnd){
                    fragment.pause();
                }
            }
        }
        //初始化显示弹窗
        ExitDialog.Builder builder = new ExitDialog.Builder(this);
        builder.setTitle("温馨提示")
                .setMessage("是否要退出本次训练···")
                .setExitButton("退出训练", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        finish();
                    }
                })
                .setContinueButton("继续训练", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                        //继续计时
                        String TypeNo = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
                        if(TypeNo.equals("E")) {
                            CNtxlTlxzFragment fragment = (CNtxlTlxzFragment) mFragmentList.get(currentPageIndex);
                            RelativeLayout mRlMyBrowseBg = fragment.getView().findViewById(R.id.rl_myBrowseBg);
                            CountDownView mCdvMyBrowse =  fragment.getView().findViewById(R.id.cdv_myBrowse);
                            if(mRlMyBrowseBg.getVisibility()==View.VISIBLE) {
                                mCdvMyBrowse.resumeCountDown();
                            }else{
                                if(!fragment.isVoicePlayingEnd){
                                    fragment.play();
                                }
                            }
                        }else if(TypeNo.equals("S")){
                            CNtxlTltkFragment fragment = (CNtxlTltkFragment) mFragmentList.get(currentPageIndex);
                            RelativeLayout mRlMyBrowseBg = fragment.getView().findViewById(R.id.rl_myBrowseBg);
                            CountDownView mCdvMyBrowse =  fragment.getView().findViewById(R.id.cdv_myBrowse);
                            if(mRlMyBrowseBg.getVisibility()==View.VISIBLE) {
                                mCdvMyBrowse.resumeCountDown();
                                Log.e("back","========mRlMyBrowseBg====2222222==============");
                            }else{
                                if(!fragment.isVoicePlayingEnd){
                                    Log.e("back","========mRlMyBrowseBg====333333333==============");
                                    fragment.play();
                                }
                            }
                        }
                    }
                }).create().show();
    }


    /*
    * 收藏Post请求
    * */
    private void postCollection(int position,int collectionFlag) {

        String QuesBreaf = CNtxlPaperEntity.get(position).getQuesFromTK().getQuesBrief();
        String QuesID = CNtxlPaperEntity.get(position).getQuesFromTK().getQuesID();
        String TypeNo = CNtxlPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        String GenreID = CNtxlPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();

        PostCollectionJson postCollectionJson =new PostCollectionJson();
        postCollectionJson.setKey(UserInfoBean.Key);
        postCollectionJson.setCourseClassID(UserInfoBean.CourseClassID);
        postCollectionJson.setFlag(collectionFlag);
        postCollectionJson.setGenreID(GenreID);
        postCollectionJson.setGlobalGrade(UserInfoBean.GlobalGrade);
        postCollectionJson.setQuesBrief(QuesBreaf);
        postCollectionJson.setQuesID(QuesID);
        postCollectionJson.setTypeNo(TypeNo);
        postCollectionJson.setSchoolID(UserInfoBean.SchoolID);
        postCollectionJson.setStuID(UserInfoBean.StuId);
        postCollectionJson.setSubjectID(UserInfoBean.SubjectID);
        Gson gson=new Gson();
        String BODY= gson.toJson(postCollectionJson);
        Log.e("==BODY_ABCD=","========BODY====请求参数============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory( GsonConverterFactory.create())
                .build();
        PostCollection_interface postRequest = retrofit.create(PostCollection_interface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<Integer> call = postRequest.postCollection(body);
        call.enqueue(new Callback<Integer>() {
            @Override
            public void onResponse(Call<Integer> call, Response<Integer> response) {
                String result = response.body().toString();
                Log.e("onResponse=","===============成功============="+result);
            }

            @Override
            public void onFailure(Call<Integer> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
            }
        });

    }

    //提交客观题作答信息
    private void SubmitCntxlKgtQuesAnswer(int position) {

        double CorrectRate = 0;
        List<SubmitQuesAnswerModel.ChildListBean> ChildList = new ArrayList<>();
        String TypeNo = CNtxlPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        if(TypeNo.equals("A")||TypeNo.equals("E")||TypeNo.equals("D")||TypeNo.equals("C")){

            int AnsweredCountTrue = 0;
            int ChildListSize =  CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
            for(int i=0;i<ChildListSize;i++) {
                SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                        new SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean();
                String AudioPath =  CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
                String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
                String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
                String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                subChildItemBean.setAudioPath(AudioPath);
                subChildItemBean.setImagePath(ImagePath);
                subChildItemBean.setItemAnswer(ItemAnswer);
                subChildItemBean.setItemIndex(ItemIndex);
                subChildItemBean.setScoreRate(0);
                subChildItemBean.setStuAnswer(StuAnswer);
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                SubChildItem.add(subChildItemBean);

                SubmitQuesAnswerModel.ChildListBean.SubChildListBean subChildListBean =
                        new SubmitQuesAnswerModel.ChildListBean.SubChildListBean();
                int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
                        getSubChildList().get(0).getSubChildIndex();
                subChildListBean.setSubChildIndex(SubChildIndex);
                subChildListBean.setSubChildItem(SubChildItem);
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                SubChildList.add(subChildListBean);

                SubmitQuesAnswerModel.ChildListBean childListBean =
                        new SubmitQuesAnswerModel.ChildListBean();
                int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
                childListBean.setChildIndex(ChildIndex);
                childListBean.setSubChildList(SubChildList);

                ChildList.add(childListBean);

                if(ItemAnswer.equals(StuAnswer)){
                    AnsweredCountTrue = AnsweredCountTrue+1;
                }

            }
            int QuesAnswerSize = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
            CorrectRate = LancooUtils.getCorrectRate(AnsweredCountTrue,QuesAnswerSize);

        }else if(TypeNo.equals("S")||TypeNo.equals("N")||TypeNo.equals("Q")||TypeNo.equals("m")){

            String GenreName = CNtxlPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreName();
            if(GenreName.equals("选词填空")){
                int AnsweredCountTrue = 0;
                int ChildListSize =  CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<ChildListSize;i++) {
                    SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                            new SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean();
                    String AudioPath =  CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
                    String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                    int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                    subChildItemBean.setAudioPath(AudioPath);
                    subChildItemBean.setImagePath(ImagePath);
                    subChildItemBean.setItemAnswer(ItemAnswer);
                    subChildItemBean.setItemIndex(ItemIndex);
                    subChildItemBean.setScoreRate(0);
                    subChildItemBean.setStuAnswer(StuAnswer);
                    List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                    SubChildItem.add(subChildItemBean);

                    SubmitQuesAnswerModel.ChildListBean.SubChildListBean subChildListBean =
                            new SubmitQuesAnswerModel.ChildListBean.SubChildListBean();
                    int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
                            getSubChildList().get(0).getSubChildIndex();
                    subChildListBean.setSubChildIndex(SubChildIndex);
                    subChildListBean.setSubChildItem(SubChildItem);
                    List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                    SubChildList.add(subChildListBean);

                    SubmitQuesAnswerModel.ChildListBean childListBean =
                            new SubmitQuesAnswerModel.ChildListBean();
                    int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
                    childListBean.setChildIndex(ChildIndex);
                    childListBean.setSubChildList(SubChildList);

                    ChildList.add(childListBean);

                    if(ItemAnswer.equals(StuAnswer)){
                        AnsweredCountTrue = AnsweredCountTrue+1;
                    }

                }
                int QuesAnswerSize = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                CorrectRate = LancooUtils.getCorrectRate(AnsweredCountTrue,QuesAnswerSize);
            }else{
                int AnsweredCountTrue = 0;
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                int Size =  CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().get(0).getSubChildList().get(0).getSubChildItem().size();
                for(int i=0;i<Size;i++) {
                    SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                            new SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean();
                    String AudioPath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getAudioPath();
                    String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getImagePath();
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                    int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemIndex();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                    subChildItemBean.setAudioPath(AudioPath);
                    subChildItemBean.setImagePath(ImagePath);
                    subChildItemBean.setItemAnswer(ItemAnswer);
                    subChildItemBean.setItemIndex(ItemIndex);
                    subChildItemBean.setScoreRate(0);
                    subChildItemBean.setStuAnswer(StuAnswer);

                    if(ItemAnswer.equals(StuAnswer)){
                        AnsweredCountTrue = AnsweredCountTrue+1;
                    }

                    SubChildItem.add(subChildItemBean);
                }

                SubmitQuesAnswerModel.ChildListBean.SubChildListBean subChildListBean =
                        new SubmitQuesAnswerModel.ChildListBean.SubChildListBean();
                int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(0).
                        getSubChildList().get(0).getSubChildIndex();
                subChildListBean.setSubChildIndex(SubChildIndex);
                subChildListBean.setSubChildItem(SubChildItem);
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                SubChildList.add(subChildListBean);

                SubmitQuesAnswerModel.ChildListBean childListBean =
                        new SubmitQuesAnswerModel.ChildListBean();
                int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(0).getChildIndex();
                childListBean.setChildIndex(ChildIndex);
                childListBean.setSubChildList(SubChildList);

                ChildList.add(childListBean);

                int QuesAnswerSize = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getChildList().size();
                CorrectRate = LancooUtils.getCorrectRate(AnsweredCountTrue,QuesAnswerSize);
            }
        }

        SubmitQuesAnswerModel mSubmitQuesAnswerModel = new SubmitQuesAnswerModel();
        String GenreID = CNtxlPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();
        String QuesID = CNtxlPaperEntity.get(position).getQuesFromTK().getQuesID();
        mSubmitQuesAnswerModel.setChildList(ChildList);
        mSubmitQuesAnswerModel.setCorrectRate(CorrectRate);
        mSubmitQuesAnswerModel.setCourseClassID(UserInfoBean.CourseClassID);
        mSubmitQuesAnswerModel.setDuration(10);//待传（需计算）
        mSubmitQuesAnswerModel.setGenreID(GenreID);
        mSubmitQuesAnswerModel.setGlobalGrade(UserInfoBean.GlobalGrade);
        mSubmitQuesAnswerModel.setItemType(ItemType);//1--错题；3--难题
        mSubmitQuesAnswerModel.setQuesID(QuesID);
        mSubmitQuesAnswerModel.setSchoolID(UserInfoBean.SchoolID);
        mSubmitQuesAnswerModel.setStuID(UserInfoBean.StuId);
        mSubmitQuesAnswerModel.setState(2);
        mSubmitQuesAnswerModel.setTypeNo(TypeNo);
        mSubmitQuesAnswerModel.setSubjectID(UserInfoBean.SubjectID);
        mSubmitQuesAnswerModel.setKey(UserInfoBean.Key);


        Gson gson=new Gson();
        String BODY= gson.toJson(mSubmitQuesAnswerModel);
        Log.e("==BODYAABB=","========BODY====请求参数=====AAAAA=============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory( GsonConverterFactory.create())
                .build();
        PostSubmitKgtQuesAnswer_Interface postRequest = retrofit.create(PostSubmitKgtQuesAnswer_Interface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<String> call = postRequest.submitCNtxlKgtQuesAnswer(body);
        call.enqueue(new Callback<String>() {
            @Override
            public void onResponse(Call<String> call, Response<String> response) {
                Log.e("onResponse=","===============成功=============");
            }

            @Override
            public void onFailure(Call<String> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
            }
        });

    }

    //提交大数据评阅作答信息
    private boolean isCouldMoveNextPage_zgt = false;
    private void SubmitCntxlZgtQuesAnswer(final int position) {

        mLoadingDialog = new LoadingDialog(this,false,false,"智能评测中...");
        mLoadingDialog.show();

        List<SubmitQuesAnswerModel.ChildListBean> ChildList = new ArrayList<>();
        String TypeNo = CNtxlPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        if(TypeNo.equals("f")||TypeNo.equals("V")||TypeNo.equals("X")||TypeNo.equals("d")||TypeNo.equals("g")){

            int ChildListSize =  CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
            for(int i=0;i<ChildListSize;i++) {
                SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                        new SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean();
                String AudioPath =  CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getAudioPath();
                String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getImagePath();
                String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemIndex();
                String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                subChildItemBean.setAudioPath(AudioPath);
                subChildItemBean.setImagePath(ImagePath);
                subChildItemBean.setItemAnswer(ItemAnswer);
                subChildItemBean.setItemIndex(ItemIndex);
                subChildItemBean.setScoreRate(0);
                subChildItemBean.setStuAnswer(StuAnswer);
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                SubChildItem.add(subChildItemBean);

                SubmitQuesAnswerModel.ChildListBean.SubChildListBean subChildListBean =
                        new SubmitQuesAnswerModel.ChildListBean.SubChildListBean();
                int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
                        getSubChildList().get(0).getSubChildIndex();
                subChildListBean.setSubChildIndex(SubChildIndex);
                subChildListBean.setSubChildItem(SubChildItem);
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                SubChildList.add(subChildListBean);

                SubmitQuesAnswerModel.ChildListBean childListBean =
                        new SubmitQuesAnswerModel.ChildListBean();
                int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
                childListBean.setChildIndex(ChildIndex);
                childListBean.setSubChildList(SubChildList);

                ChildList.add(childListBean);

            }

        }else if(TypeNo.equals("b")||TypeNo.equals("k")){
            int ChildListSize = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
            for(int i=0;i<ChildListSize;i++) {

                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean> SubChildItem = new ArrayList<>();
                int SubChildItemSize = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().
                        get(i).getSubChildList().get(0).getSubChildItem().size();
                for(int j=0;j<SubChildItemSize;j++){
                    SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean subChildItemBean =
                            new SubmitQuesAnswerModel.ChildListBean.SubChildListBean.SubChildItemBean();
                    String AudioPath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getAudioPath();
                    String ImagePath = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getImagePath();
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getItemAnswer();
                    int ItemIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getItemIndex();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(j).getStuAnswer();

                    double ScoreRate = 0;
                    String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswer,"$/",2);
                    List<String> list=Arrays.asList(ItemAnswerArray);
                    if(list.contains(StuAnswer)){
                        ScoreRate = 1;
                    }

                    subChildItemBean.setAudioPath(AudioPath);
                    subChildItemBean.setImagePath(ImagePath);
                    subChildItemBean.setItemAnswer(ItemAnswer);
                    subChildItemBean.setItemIndex(ItemIndex);
                    subChildItemBean.setScoreRate(ScoreRate);
                    subChildItemBean.setStuAnswer(StuAnswer);

                    SubChildItem.add(subChildItemBean);
                }

                SubmitQuesAnswerModel.ChildListBean.SubChildListBean subChildListBean =
                        new SubmitQuesAnswerModel.ChildListBean.SubChildListBean();
                int SubChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).
                        getSubChildList().get(0).getSubChildIndex();
                subChildListBean.setSubChildIndex(SubChildIndex);
                subChildListBean.setSubChildItem(SubChildItem);
                List<SubmitQuesAnswerModel.ChildListBean.SubChildListBean> SubChildList = new ArrayList<>();
                SubChildList.add(subChildListBean);

                SubmitQuesAnswerModel.ChildListBean childListBean =
                        new SubmitQuesAnswerModel.ChildListBean();
                int ChildIndex = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().get(i).getChildIndex();
                childListBean.setChildIndex(ChildIndex);
                childListBean.setSubChildList(SubChildList);

                ChildList.add(childListBean);

            }
        }

        SubmitQuesAnswerModel mSubmitQuesAnswerModel = new SubmitQuesAnswerModel();
        String GenreID = CNtxlPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();
        String QuesID = CNtxlPaperEntity.get(position).getQuesFromTK().getQuesID();
        mSubmitQuesAnswerModel.setChildList(ChildList);
        mSubmitQuesAnswerModel.setCorrectRate(0);
        mSubmitQuesAnswerModel.setCourseClassID(UserInfoBean.CourseClassID);
        mSubmitQuesAnswerModel.setDuration(10);//待传（需计算）
        mSubmitQuesAnswerModel.setGenreID(GenreID);
        mSubmitQuesAnswerModel.setGlobalGrade(UserInfoBean.GlobalGrade);
        mSubmitQuesAnswerModel.setItemType(ItemType);//1--错题；3--难题
        mSubmitQuesAnswerModel.setQuesID(QuesID);
        mSubmitQuesAnswerModel.setSchoolID(UserInfoBean.SchoolID);
        mSubmitQuesAnswerModel.setStuID(UserInfoBean.StuId);
        mSubmitQuesAnswerModel.setState(0);
        mSubmitQuesAnswerModel.setTypeNo(TypeNo);
        mSubmitQuesAnswerModel.setSubjectID(UserInfoBean.SubjectID);
        mSubmitQuesAnswerModel.setKey(UserInfoBean.Key);

        Gson gson=new Gson();
        String BODY= gson.toJson(mSubmitQuesAnswerModel);
        Log.e("==BODYAABB=","========BODY====请求参数=====AAAAA=============="+BODY);
        String BASE_URL = URLConstant.BASE_URL;
        Retrofit retrofit=new Retrofit.Builder()
                .baseUrl(BASE_URL)
                .addConverterFactory( GsonConverterFactory.create())
                .build();
        PostSubmitZgtQuesAnswer_Interface postRequest = retrofit.create(PostSubmitZgtQuesAnswer_Interface.class);
        RequestBody body=RequestBody.create(okhttp3.MediaType.parse("application/json; charset=utf-8"),BODY);
        Call<List<ResultZgtJson>> call = postRequest.submitCNtxlZgtQuesAnswer(body);
        call.enqueue(new Callback<List<ResultZgtJson>>() {
            @Override
            public void onResponse(Call<List<ResultZgtJson>> call, Response<List<ResultZgtJson>> response) {

                doRefreshCurrentPageView(position);
                mLoadingDialog.dismiss();

                Log.e("onResponse=","===============成功=====1111========"+response.body().get(0).getScoreRate());
                int size = response.body().size();
                final String TypeNo = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
                for(int i=0;i<size;i++){
                    double ScoreRate = response.body().get(i).getScoreRate();
                    if(TypeNo.equals("k")) {

                    }else if(TypeNo.equals("b")){
                        CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                get(0).getSubChildList().get(0).getSubChildItem().get(i).setScoreRate(ScoreRate);
                    }else{
                        CNtxlPaperEntity.get(currentPageIndex).getFavouriteAndNote().getChildList().
                                get(i).getSubChildList().get(0).getSubChildItem().get(0).setScoreRate(ScoreRate);
                    }
                }


                isCouldMoveNextPage_zgt = true;
                for(int i=0;i<size;i++){
                    if(response.body().get(i).getScoreRate()<0.6){
                        isCouldMoveNextPage_zgt = false;
                        break;
                    }
                }

                final Handler mH = new Handler();
                mH.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        if(isCouldMoveNextPage_zgt){
                            int PageSize = CNtxlPaperEntity.size();
                            if(currentPageIndex<PageSize-1){
                                mVpCNtxl.setCurrentItem(currentPageIndex+1);
                            }else{
                                LancooUtils.showShort(CNtxlActivity.this,"没有更多题目了");
                            }
                        }else{
                            if(TypeNo.equals("k")){
                                CNtxlYdzhFragment fragment = (CNtxlYdzhFragment) mFragmentList.get(currentPageIndex);
                                mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                                mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                                mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        LancooUtils.showShort(CNtxlActivity.this, "进入阅读综合题同类题训练");
                                        setSameQuesInitParma();
                                    }
                                });
                            }else {
                                CNtxlYdjdFragment fragment = (CNtxlYdjdFragment) mFragmentList.get(currentPageIndex);
                                mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                                mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                                mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View v) {
                                        LancooUtils.showShort(CNtxlActivity.this, "进入简答题同类题训练");
                                        setSameQuesInitParma();
                                    }
                                });
                            }

                            if(PhoneMainActivity.getCNtxlModel()==1) {
                                showSameQuesTranslateView();
                            }
                        }
                       mH.removeCallbacks(this);
                    }
                },200);


            }

            @Override
            public void onFailure(Call<List<ResultZgtJson>> call, Throwable t) {
                Log.e("onFailure", t.getMessage());
            }
        });

    }

    private void doRefreshCurrentPageView(int position){
        String TypeNo = CNtxlPaperEntity.get(position).getQuesFromTK().getTypeInfo().getTypeNo();
        //刷新上一页作答界面详情
        int SubmitState  = CNtxlPaperEntity.get(position).getFavouriteAndNote().getSubmitState();
        if(SubmitState==2) {

            if(TypeNo.equals("E")) {
                CNtxlTlxzFragment fragment = (CNtxlTlxzFragment) mFragmentList.get(position);
                RelativeLayout mRlMyBrowseBg = fragment.getView().findViewById(R.id.rl_myBrowseBg);
                mRlMyBrowseBg.setVisibility(View.GONE);
                RelativeLayout mRlMyRecordMiBg = fragment.getView().findViewById(R.id.rl_myRecordBg);
                mRlMyRecordMiBg.setVisibility(View.GONE);
                RelativeLayout mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                ScaleButton mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                fragment.pause();
                //显示听力原文
                TextView mTvListenScript = fragment.getView().findViewById(R.id.tv_listenScript);
                mTvListenScript.setVisibility(View.VISIBLE);
                String ListenScript  = CNtxlPaperEntity.get(position).getQuesFromTK().getAudioList().get(0).getText();
                CharSequence ListenScriptA = Html.fromHtml("听力原文<br><br>"+ListenScript);
                int ImprotantZSDSize = CNtxlPaperEntity.get(position).getQuesFromTK().getImprotantZSD().size();
                String[] keyword = new String[ImprotantZSDSize];
                String[] keywordCode = new String[ImprotantZSDSize];
                for(int i=0;i<ImprotantZSDSize;i++){
                    keyword[i] = CNtxlPaperEntity.get(position).getQuesFromTK().getImprotantZSD().get(i).getName();
                    keywordCode[i] = CNtxlPaperEntity.get(position).getQuesFromTK().getImprotantZSD().get(i).getCode();
                }
                SpannableString highlightText = HighLightKeyWordUtil.highlight(ListenScriptA.toString(), keyword, keywordCode,"#FF0000");
                mTvListenScript.setText(highlightText);
                mTvListenScript.setMovementMethod(LinkMovementMethod.getInstance());//设置可点击状态

                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int totalItemCount = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<totalItemCount;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                    CNtxlTlxzAnswerAdapter mCNtxlTlxzAnswerAdapter = new CNtxlTlxzAnswerAdapter(CNtxlActivity.this,
                            CNtxlPaperEntity,position,i,new CNtxlTlxzAnswerAdapter.CallBackAdapterTlxz() {
                        @Override
                        public void callAnsweredAll() {

                        }

                    });
                    mRvAnswer.setAdapter(mCNtxlTlxzAnswerAdapter);
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerTlxz);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( CNtxlPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

                int AnswerSize = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().size();
                for(int i=0;i<AnswerSize;i++) {
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                    if (!ItemAnswer.equals(StuAnswer)) {
                        mRlControlView.setVisibility(View.VISIBLE);
                        mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                setSameQuesInitParma();
                            }
                        });
                        break;
                    }
                }

                SubmitCntxlKgtQuesAnswer(position);

            }else if(TypeNo.equals("C")){
                CNtxlWxxzFragment fragment = (CNtxlWxxzFragment) mFragmentList.get(position);
                RelativeLayout mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                ScaleButton mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int totalItemCount = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<totalItemCount;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                    CNtxlWxxzAnswerAdapter mAnswerAdapter = new CNtxlWxxzAnswerAdapter(CNtxlActivity.this,
                            CNtxlPaperEntity,position,i,new CNtxlWxxzAnswerAdapter.CallBackAdapterWxxz(){
                        @Override
                        public void callHideRecordMiView() {

                        }

                        @Override
                        public void callRefreshClickAnswer() {

                        }

                        @Override
                        public void callClickWhichIndex(String stuAnswer) {

                        }

                    });
                    mRvAnswer.setAdapter(mAnswerAdapter);
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerWxxz);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( CNtxlPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

                int AnswerSize = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().size();
                for(int i=0;i<AnswerSize;i++) {
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                    if (!ItemAnswer.equals(StuAnswer)) {
                        mRlControlView.setVisibility(View.VISIBLE);
                        mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                setSameQuesInitParma();
                            }
                        });
                        break;
                    }
                }

                SubmitCntxlKgtQuesAnswer(position);

            }else if(TypeNo.equals("m")){
                CNtxlPptFragment fragment = (CNtxlPptFragment) mFragmentList.get(position);
                RelativeLayout mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                ScaleButton mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int totalItemCount = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().
                        get(0).getSubChildList().get(0).getSubChildItem().size();
                for(int i=0;i<totalItemCount;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                    CNtxlPptAnswerAdapter mAnswerAdapter = new CNtxlPptAnswerAdapter(CNtxlActivity.this,
                            CNtxlPaperEntity,position,new CNtxlPptAnswerAdapter.CallBackAdapterPpt(){

                        @Override
                        public void callHideRecordMiView() {

                        }

                        @Override
                        public void callClickWhichIndex(String stuAnswer) {

                        }

                        @Override
                        public void callRefreshClickAnswer() {

                        }
                    });
                    mRvAnswer.setAdapter(mAnswerAdapter);
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerPpt);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( CNtxlPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

                int AnswerSize = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(0).getSubChildList().get(0).getSubChildItem().size();
                for(int i=0;i<AnswerSize;i++) {
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                    if (!ItemAnswer.equals(StuAnswer)) {
                        mRlControlView.setVisibility(View.VISIBLE);
                        mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                setSameQuesInitParma();
                            }
                        });
                        break;
                    }
                }

                SubmitCntxlKgtQuesAnswer(position);

            }else if(TypeNo.equals("D")){
                CNtxlYdxzFragment fragment = (CNtxlYdxzFragment) mFragmentList.get(position);
                RelativeLayout mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                ScaleButton mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int totalItemCount = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<totalItemCount;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                    CNtxlYdxzAnswerAdapter mAnswerAdapter = new CNtxlYdxzAnswerAdapter(CNtxlActivity.this,
                            CNtxlPaperEntity,position,i,new CNtxlYdxzAnswerAdapter.CallBackAdapterYdxz(){
                        @Override
                        public void callAnsweredAll() {

                        }

                    });
                    mRvAnswer.setAdapter(mAnswerAdapter);
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerYdxz);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( CNtxlPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

                int AnswerSize = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().size();
                for(int i=0;i<AnswerSize;i++) {
                    String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                    String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                            get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                    if (!ItemAnswer.equals(StuAnswer)) {
                        mRlControlView.setVisibility(View.VISIBLE);
                        mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                setSameQuesInitParma();
                            }
                        });
                        break;
                    }
                }

                SubmitCntxlKgtQuesAnswer(position);

            }else if(TypeNo.equals("N")||TypeNo.equals("Q")){
                CNtxlTktFragment fragment = (CNtxlTktFragment) mFragmentList.get(position);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                CNtxlTktAnswerAdapter mAnswerAdapter = new CNtxlTktAnswerAdapter(CNtxlActivity.this,
                        CNtxlPaperEntity,position);
                mRvAnswer.setAdapter(mAnswerAdapter);
                list.add(mRvAnswer);
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerTkt);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));

                RelativeLayout mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                ScaleButton mSBtnSubmit  = fragment.getView().findViewById(R.id.sbtn_submit);
                mSBtnSubmit.setVisibility(View.GONE);
                ScaleButton mSBtnSameQuesTranslate  = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);

                boolean isNeedSameQuesTranslate = false;
                String GenreID = CNtxlPaperEntity.get(position).getQuesFromTK().getGenreInfo().getGenreID();
                if(GenreID.equals("选词填空")){
                    int Size = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
                    for(int i=0;i<Size;i++){
                        String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                               get(i).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                        String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                                get(i).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                        String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswer,"$/",2);
                        List<String> listItemAnswer =Arrays.asList(ItemAnswerArray);
                        if(!listItemAnswer.contains(StuAnswer)){
                            isNeedSameQuesTranslate = true;
                            break;
                        }
                    }
                }else{
                    int Size = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().get(0).getSubChildList().get(0).getSubChildItem().size();
                    for(int i=0;i<Size;i++){
                        String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                                get(0).getSubChildList().get(0).getSubChildItem().get(i).getStuAnswer();
                        String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                                get(0).getSubChildList().get(0).getSubChildItem().get(i).getItemAnswer();
                        String[] ItemAnswerArray = LancooUtils.returnArray(ItemAnswer,"$/",2);
                        List<String> listItemAnswer =Arrays.asList(ItemAnswerArray);
                        if(!listItemAnswer.contains(StuAnswer)){
                            isNeedSameQuesTranslate = true;
                            break;
                        }
                    }
                }
                if(isNeedSameQuesTranslate) {
                    mRlControlView.setVisibility(View.VISIBLE);
                    mSBtnSameQuesTranslate.setVisibility(View.VISIBLE);
                    mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            setSameQuesInitParma();
                        }
                    });
                }else{
                    mRlControlView.setVisibility(View.GONE);
                }

                SubmitCntxlKgtQuesAnswer(position);

            }else if(TypeNo.equals("A")){

                CNtxlDxtFragment fragment = (CNtxlDxtFragment) mFragmentList.get(position);
                RelativeLayout mRlControlView = fragment.getView().findViewById(R.id.rl_controlView);
                ScaleButton mSBtnSameQuesTranslate = fragment.getView().findViewById(R.id.sbtn_sameQuesTranslate);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                CNtxlDxtAnswerAdapter mAnswerAdapter = new CNtxlDxtAnswerAdapter(CNtxlActivity.this,
                        CNtxlPaperEntity,position,new CNtxlDxtAnswerAdapter.CallBackAdapterDxt(){

                    @Override
                    public void callAnsweredAll() {

                    }


                });
                mRvAnswer.setAdapter(mAnswerAdapter);
                list.add(mRvAnswer);
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerDxt);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));

                String ItemAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(0).getSubChildList().get(0).getSubChildItem().get(0).getItemAnswer();
                String StuAnswer = CNtxlPaperEntity.get(position).getFavouriteAndNote().getChildList().
                        get(0).getSubChildList().get(0).getSubChildItem().get(0).getStuAnswer();
                if(!ItemAnswer.equals(StuAnswer)){
                    mRlControlView.setVisibility(View.VISIBLE);
                    mSBtnSameQuesTranslate.setOnClickListener(new View.OnClickListener() {
                        @Override
                        public void onClick(View v) {
                            setSameQuesInitParma();
                        }
                    });
                }

                SubmitCntxlKgtQuesAnswer(position);
            }else if(TypeNo.equals("X")||TypeNo.equals("V")||TypeNo.equals("g")||TypeNo.equals("d")||TypeNo.equals("b")){

                CNtxlYdjdFragment fragment = (CNtxlYdjdFragment) mFragmentList.get(position);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int totalItemCount = CNtxlPaperEntity.get(position).getQuesFromTK().getTotalItemCount();
                for(int i=0;i<totalItemCount;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                    CNtxlYdjdAnswerAdapter mAnswerAdapter = new CNtxlYdjdAnswerAdapter(CNtxlActivity.this,
                            CNtxlPaperEntity,position,i);
                    mRvAnswer.setAdapter(mAnswerAdapter);
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerYdjd);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( CNtxlPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

            }else if(TypeNo.equals("k")){

                CNtxlYdzhFragment fragment = (CNtxlYdzhFragment) mFragmentList.get(position);
                //显示刷新作答结果
                ArrayList<View> list = new ArrayList<>();
                list.clear();
                int Size = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().size();
                for(int i=0;i<Size;i++) {
                    final RecyclerView mRvAnswer = new RecyclerView(CNtxlActivity.this);
                    mRvAnswer.setLayoutManager(new LinearLayoutManager(CNtxlActivity.this));//必须先设置LayoutManager
                    int ChildAnswerType = CNtxlPaperEntity.get(position).getQuesFromTK().getChildList().get(i).getChildAnswerType();
                    if(ChildAnswerType==2){
                        CNtxlYdzhAnswerAdapter_tk mAnswerAdapter = new CNtxlYdzhAnswerAdapter_tk(CNtxlActivity.this,
                                CNtxlPaperEntity,position,i);
                        mRvAnswer.setAdapter(mAnswerAdapter);
                    }else if(ChildAnswerType==4){
                        CNtxlYdzhAnswerAdapter_jd mAnswerAdapter = new CNtxlYdzhAnswerAdapter_jd(CNtxlActivity.this,
                                CNtxlPaperEntity,position,i);
                        mRvAnswer.setAdapter(mAnswerAdapter);
                    }
                    list.add(mRvAnswer);
                }
                ViewPager mVpAnswer = fragment.getView().findViewById(R.id.vp_answerYdjd);
                mVpAnswer.setAdapter(new AnswerViewPagerAdapter(list));
                mVpAnswer.setCurrentItem( CNtxlPaperEntity.get(position).getFavouriteAndNote().getCurrentSubChildAnswerIndex());

            }
        }
    }


    private void showSameQuesTranslateView(){
            ObjectAnimator translationY1 = ObjectAnimator.ofFloat(mRlControlView, View.TRANSLATION_Y, 300f, 0f);
            ObjectAnimator translationY2 = ObjectAnimator.ofFloat(mSBtnSameQuesTranslate, View.TRANSLATION_Y, 300f, 0f);
            AnimatorSet setShow = new AnimatorSet();
            setShow.playTogether(translationY1,translationY2);
            setShow.setDuration(600);
            setShow.addListener(new Animator.AnimatorListener() {
                @Override
                public void onAnimationStart(Animator animation) {
                    mRlControlView.setVisibility(View.VISIBLE);
                    mSBtnSameQuesTranslate.setVisibility(View.VISIBLE);
                }

                @Override
                public void onAnimationEnd(Animator animation) {

                }

                @Override
                public void onAnimationCancel(Animator animation) {

                }

                @Override
                public void onAnimationRepeat(Animator animation) {

                }
            });
            setShow.start();

    }

    private void setSameQuesInitParma(){
        SameQuesInitParam.SQ_GenreID = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getGenreInfo().getGenreID();
        SameQuesInitParam.SQ_QuesID = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getQuesID();
        SameQuesInitParam.SQ_QuesTypeID = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getTypeInfo().getTypeNo();
        SameQuesInitParam.SQ_Hval = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getHVal();
        int CodeSize = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getImprotantZSD().size();
        for(int k=0;k<CodeSize;k++){
            String Code = CNtxlPaperEntity.get(currentPageIndex).getQuesFromTK().getImprotantZSD().get(0).getCode();
            if(k==0){
                SameQuesInitParam.SQ_ImportKnCode = Code;
            }else {
                SameQuesInitParam.SQ_ImportKnCode = SameQuesInitParam.SQ_ImportKnCode+"&"+Code;
            }
        }
        startActivity(SameQuesActivity.class);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        Log.e("onDestroy","============退出错难题训练==============");
        SkEgnManager.getInstance(this).stopRecord();
    }
}